package com.stek.floaticon;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.stek.R;
import com.stek.utils.Utils;

public class FloatAdapter extends BaseAdapter {
	private Context context;
	private ArrayList<Integer> resources;

	public FloatAdapter(Context context, ArrayList<Integer> resources) {
		super();
		this.context = context;
		this.resources = resources;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return resources.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return resources.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder;
		if (null == convertView) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.view_grid, null);
			holder = new Holder();
			holder.img = (ImageView) convertView.findViewById(R.id.img);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}
		holder.img.setImageResource(resources.get(position));
		Utils.animateGridView(convertView, 2, position);
		return convertView;
	}

	static class Holder {
		ImageView img;
	}

}
